
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <style>
        *{padding: 0;margin: 0;}
        .banner{
            width: 500px;
            height: 281px;
            margin: 300px auto;
            position: relative;
        }
        .banner img{
            width: 100%;
            height: 100%;
        }
        .banner span{
            width:50px;
            height: 100px;
            background: white;
            opacity: 0.6;
            position: absolute;
            top: 50%;
            margin-top:-50px;
            font-size: 35px;
            text-align: center;
            line-height: 100px;
            cursor: pointer;
            display: none;

        }
        .left{
            left: 20px;
        }
        .right{
            right: 20px;
        }
        #banner .mask{
            width: 100%;
            height: 70px;
            background: #fff;
            opacity: 0.5;
            position: absolute;
            bottom: 0;
        }
        #banner p{
            width: 100%;
            height: 70px;
            position: absolute;
            bottom: 0;
            line-height: 70px;
            font-size: 25px;
            text-align: center;
        }
        .a1{
            text-decoration: none;
            display: block;
            width: 100px;
            height: 50px;
            background: #008ce1;
            color: white;
            margin: 50px auto;
            text-align: center;
            line-height: 50px;
        }
    </style>
</head>
<body>
<div class="banner" id="banner">
    <img src="img/tour6.jpg" alt="">
    <div class="mask"></div>
    <p>第一张图片</p>
    <span class="left">&lt;</span>
    <span class="right">&gt;</span>
</div>
</body>
</html>
<script>
    var banner=document.getElementById("banner");
    var span=document.getElementsByTagName("span");
    var img=document.getElementsByTagName("img")[0];
    var op=document.getElementsByTagName("p")[0];
    var oimg=["img/tour7.jpg","img/tour6.jpg"];
    var otext=["第一张图片","第二张图片"];
    function display(value){
        for (var i=0;i<span.length;i++){
            span[i].style.display=value;
        }
    }
    banner.onmouseover=function(){
        display("block")
    };
    banner.onmouseout=function(){
        display("none")
    };
    var a = 0;
    span[0].onclick=function(){
        if (a == 0){
            a = oimg.length -1;
        }else {
            a --;
        }
        img.src=oimg[a];
        op.innerHTML=otext[a];
    };
    span[1].onclick=function(){
        if(a==1){
            a=0;
        }else {
            a++;
        }
        img.src=oimg[a];
        op.innerHTML=otext[a];
    }
</script>